package com.util; 

import java.io.FileInputStream;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;

public class FileDownLoadData extends BaseAction { 

	

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getProid() {
		return proid;
	}

	public void setProid(String proid) {
		this.proid = proid;
	}

	public String getFileName() {
		return fileName;
	}

	private String fileName;// 初始的通过param指定的文件名属性 

	private String inputPath;// 指定要被下载的文件路径 
	
	private String id;
    
	private String proid;

	public InputStream getInputStream() throws Exception {
		String dir = "D:\\dataForPrograms\\" + proid +"\\"+id+"."+ fileName ;
		
		return new FileInputStream(dir); 	 

	} 

	public String execute() throws Exception { 
		
		return SUCCESS; 

	} 

	public void setInputPath(String value) { 

		inputPath = value; 

	} 

	public void setFileName(String fileName) { 
	
		this.fileName = fileName; 

	} 

	/** 提供转换编码后的供下载用的文件名 */ 

	public String getDownloadFileName() { 

//		String downFileName = fileName; 
		String downFileName = id+"."+fileName; 

		try { 

			downFileName = new String(downFileName.getBytes(), "utf-8"); 

		} catch (UnsupportedEncodingException e) { 

			e.printStackTrace(); 

		} 

		return downFileName; 

	} 

} 

